/*
 * Copyright (C) 2023 InConnect. All rights reserved.
 */
package app

import (
	"embed"
	"github.com/BurntSushi/toml"
)

var (
	// Config global
	Config = &ConfigData{}
	// Embeded Resources
	ResourceFS embed.FS
)

type ConfigData struct {
	Common *CommonConfig
	Log    *LogConfig
}

type CommonConfig struct {
	Addr         string
	PowerbyName  string
	PowerbyUrl   string
	RootAccount  string
	RootPassword string
	LobbyMsg     string
	AdminMsg     string
}

type LogConfig struct {
	FileName   string
	Level      string
	MaxSize    int
	MaxAge     int
	MaxBackups int
	LocalTime  bool
	Compress   bool
}

func LoadConfig(confPath *string) (err error) {
	_, err = toml.DecodeFile(*confPath, &Config)
	return
}
